//
//  HBSettingCtrl.m
//  HuoBao
//
//  Created by chaiyanan on 15/12/4.
//  Copyright © 2015年 jinxin. All rights reserved.
//

#import "HBSettingCtrl.h"
#import "HBSettingHeaderCell.h"
#import "HBSettingCell.h"

#import "HBFeedBackCtrl.h"

#import "LCCustomerActionSheet.h"

#import "HBUploadImgInfo.h"
#import "HBUploadImgParam.h"
#import "HBUploadImgParser.h"

#import "HBLogoutParam.h"
#import "HBLogoutParser.h"
#import "HBChangePaw.h"

#import "UIImageView+WebCache.h"
#import "UMSocialQQHandler.h"
#import "UMSocial.h"

//-----------test start-----------------------
#import "CustomerBankCardSuc.h"
#import "CustomerPhoneNum.h"
#import "CustomerCardOwner.h"
#import "CustomerTestView.h"
#import "CustomMoneyNotEnogh.h"
#import "CustomTradePassword.h"
#import "CustomSuggestionAlert.h"
#import "CustomReleaseBankBindAlert.h"
//-----------test end-----------------------

#import "HBUserOpenPushParam.h"
#import "HBUserOpenPushParser.h"
#import "HBUserClosePushParam.h"
#import "HBUserClosePushParser.h"
#import "HBGetUserInfoManager.h"

#import "HBGetCusomterServicePhoneInfo.h"
#import "HBGetCustomerServicePhoneParam.h"
#import "HBGetCustomerServicePhoneParser.h"

#import "HBGetIosEvaluateUrlInfo.h"
#import "HBGetIosEvaluateUrlParam.h"
#import "HBGetIosEvaluateUrlParser.h"

@interface HBSettingCtrl ()
<
UITableViewDataSource,
UITableViewDelegate,
UINavigationControllerDelegate,
UIImagePickerControllerDelegate,
UIAlertViewDelegate,
UIWebViewDelegate
>


@property (nonatomic, strong) UITableView *tableView;
@property (nonatomic, strong) NSArray *dataAry;

@property (nonatomic, strong) UIButton *quitBtn;
@property (nonatomic, strong) HBGetCusomterServicePhoneInfo *phoneInfo;

@end

@implementation HBSettingCtrl

#pragma mark - system

- (void)viewDidLoad
{
    [super viewDidLoad];
    self.dataAry = @[
                     @[@""],
                     @[@"修改密码",@"",@"通知设置"],
                     @[@"给个好评",@"",@"问题吐槽"],
                     @[@"QQ客服",@"",@"客服热线:4008756009"]
//                     @[@"清除缓存"]
    ];
    self.phoneInfo = [[HBGetCusomterServicePhoneInfo alloc]init];
    self.phoneInfo.customerServicePhone = @"4008756009";
    self.phoneInfo.customerServiceQQ = @"4008756009";
}

- (void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:YES];
}

- (void)buildLayout
{
    [super buildLayout];
    self.title = @"设置";
    _tableView = [[UITableView alloc]initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT-64-44)];
    [self.view addSubview:_tableView];
    INIT_TABLE(_tableView);
    
    self.quitBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    self.quitBtn.frame = CGRectMake(0, SCREEN_HEIGHT-64-44, SCREEN_WIDTH, 44);
    [self.quitBtn setTitle:@"退出登录" forState:UIControlStateNormal];
    self.quitBtn.titleLabel.font = [UIFont systemFontOfSize:16.0f];
    [self.quitBtn setBackgroundColor:[LCCommon getColor:@"939393"] forState:UIControlStateNormal];
    [self.quitBtn setBackgroundColor:[LCCommon getColor:@"807e7e"] forState:UIControlStateHighlighted];
    [self.quitBtn setTitleColor:[LCCommon getColor:@"333333"] forState:UIControlStateNormal];
    [self.quitBtn addTarget:self action:@selector(clickToQuitLogin) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:self.quitBtn];
//    [self requestToGetServicePhone];
    
}

#pragma mark - private

- (void)uploadSettingHeaderCell:(HBSettingHeaderCell *)cell atIndexPath:(NSIndexPath *)indexPath
{
    [cell.headImageView setImageWithURL:[NSURL URLWithString:[HBLoginManager sharedHBLoginManager].currentUserInfo.headImg] placeholderImage:[UIImage imageNamed:@"mine_holdplace"]];
    cell.nameLable.text = [HBLoginManager sharedHBLoginManager].currentUserInfo.username;
    cell.phoneLable.text = [HBLoginManager sharedHBLoginManager].currentUserInfo.mobile;
}

- (void)uploadSettingCell:(HBSettingCell *)cell atIndexPath:(NSIndexPath *)indexPath
{
    
    NSString *title = self.dataAry[indexPath.section][indexPath.row];
    if([title isEqualToString:@"通知设置"])
    {
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
        cell.titleLable.textAlignment = NSTextAlignmentLeft;
        cell.arrowImageView.hidden = YES;
        cell.mySwitch.hidden = NO;
        if (![[HBLoginManager sharedHBLoginManager].currentUserInfo.pushStatus integerValue])
        {
            cell.mySwitch.on = YES;
        }
        else
        {
            cell.mySwitch.on = NO;
        }
        cell.ActionSwitchChange = ^(UISwitch *mySwitch)
        {
            if (!mySwitch.isOn)
            {
                [self requestToClosePush];
//                mySwitch.on = NO;
            }
            else
            {
                [self requestToOpenPush];
//                mySwitch.on = YES;
            }
        };
        
    }
    else if ([title isEqualToString:@"清除缓存"])
    {
//        cell.selectionStyle = UITableViewCellSelectionStyleDefault;
        cell.titleLable.textAlignment = NSTextAlignmentCenter;
        cell.arrowImageView.hidden = YES;
        cell.mySwitch.hidden = YES;
    }
    else if ([title hasPrefix:@"客服热线"])
    {
//        cell.selectionStyle = UITableViewCellSelectionStyleDefault;
        NSString *titletext = @"客服热线: 4008756009";
        if (self.phoneInfo)
        {
            titletext = [NSString stringWithFormat:@"客服热线: %@",self.phoneInfo.customerServicePhone];
            
        }
        cell.titleLable.text = titletext;
        cell.titleLable.textAlignment = NSTextAlignmentLeft;
        cell.arrowImageView.hidden = NO;
        cell.mySwitch.hidden = YES;
    }
    else
    {
//        cell.selectionStyle = UITableViewCellSelectionStyleDefault;
        cell.titleLable.textAlignment = NSTextAlignmentLeft;
        cell.arrowImageView.hidden = NO;
        cell.mySwitch.hidden = YES;
    }
    
    cell.titleLable.text = title;
}


#pragma mark - photo privateMethod
- (void)openImagePickerWithSourcheType:(UIImagePickerControllerSourceType)sourceType
{
    if (sourceType == UIImagePickerControllerSourceTypeCamera)
    {
        if(![UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera])
        {
            [[[UIAlertView alloc]initWithTitle:@"提示" message:@"该设备不支持相机" delegate:nil cancelButtonTitle:@"确定" otherButtonTitles:nil] show];
            return;
        }
    }
    
    UIImagePickerController * picker = [[UIImagePickerController alloc]init];
    picker.sourceType = sourceType;
    picker.delegate = self;
    picker.allowsEditing = YES;
    
    [self presentViewController:picker animated:YES completion:nil];
}


#pragma mark - imagePickerDelegate

- ( void )imagePickerController:( UIImagePickerController *)picker didFinishPickingMediaWithInfo:( NSDictionary *)info
{
    UIImage *image=[info objectForKey:UIImagePickerControllerOriginalImage];
    image = [info objectForKey:UIImagePickerControllerEditedImage];
    
    if (picker.sourceType == UIImagePickerControllerSourceTypeCamera)
    {
        UIImageWriteToSavedPhotosAlbum(image, nil, nil, nil);
    }
    [self requestToUploadImgWithImageData:UIImageJPEGRepresentation(image, 0.5)];
    [self dismissViewControllerAnimated:YES completion:^{
        
    }];
}


- ( void )imagePickerControllerDidCancel:( UIImagePickerController *)picker
{
    [self dismissViewControllerAnimated:YES completion:nil];
}


#pragma mark - active

- (void)clickToQuitLogin
{
    [self requestTologout];
//    [HBLoginManager didLoginOut];
}

- (void)clickToMakePhone
{
    [[[UIAlertView alloc]initWithTitle:@"提示" message:@"确定要拨打电话吗" delegate:self cancelButtonTitle:@"拨打" otherButtonTitles:@"取消", nil]show];
    
}

#pragma mark - alertView delegate

- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
    if (buttonIndex==0)
    {

        NSString* telPhNumber = @"tel://4008756009";
        if (self.phoneInfo)
        {
            telPhNumber = [NSString stringWithFormat:@"tel://%@",self.phoneInfo.customerServicePhone];
        }
        [[UIApplication sharedApplication] openURL:[NSURL URLWithString:telPhNumber]];
    }
}

#pragma mark - delegate&datasource

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return self.dataAry.count;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return [self.dataAry[section] count];
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    NSString *cellIdentifier = nil;
    if (indexPath.section==0)
    {
        cellIdentifier = NSStringFromClass([HBSettingHeaderCell class]);
    }
    else
    {
        if (indexPath.row==1)
        {
            cellIdentifier = @"emptyCell";
        }
        else
        {
            cellIdentifier = NSStringFromClass([HBSettingCell class]);
        }
    }
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier];
    
    if (indexPath.section==0)
    {
        if (!cell)
        {
            cell = [[HBSettingHeaderCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifier];
        }
    }
    else
    {
        if (indexPath.row==1)
        {
            if (!cell)
            {
                cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifier];
                cell.backgroundColor = [UIColor clearColor];
            }
        }
        else
        {
            if (!cell)
            {
                cell = [[HBSettingCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifier];
            }
        }
    }
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    
    if (indexPath.section==0)
    {
        [self uploadSettingHeaderCell:(HBSettingHeaderCell *)cell atIndexPath:indexPath];
    }
    else
    {
        if (indexPath.row==1)
        {
            
        }
        else
        {
            [self uploadSettingCell:(HBSettingCell *)cell atIndexPath:indexPath];
        }
    }
    
   
    return cell;
}

- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
    if (section==0)
    {
        return 10.0f;
    }
    else
    {
        return 20.0f;
    }
}

- (nullable UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
    CGFloat height = 10.0f;
    if (section!=0)
    {
        height = 20.0f;
    }
    UIView *view = [[UIView alloc]initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, height)];
    view.backgroundColor = [UIColor clearColor];
    return view;
}

- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
{
    return 1/[UIScreen mainScreen].scale;
}

- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section
{
    UIView *view = [[UIView alloc]initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 1/[UIScreen mainScreen].scale)];
    view.backgroundColor = [UIColor clearColor];
    return view;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (indexPath.section==0)
    {
        return Height_HBSettingHeaderCell;
    }
    else
    {
        if (indexPath.row==1)
        {
            return 1/([UIScreen mainScreen].scale);
        }
        else
        {
            return Height_HBSettingCell;
        }
    }

}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
    if (indexPath.section==0)
    {
        [[[LCCustomerActionSheet sharedLCCustomerActionSheet] initWithTitle:nil cancelButtonTitle:@"取消" cancelButtonAction:nil otherButtonTitles:@[@"拍照",@"相册选取"] otherButtonAction:^(NSInteger index,LCCustomerActionSheet *actionSheet)
          {
              if (index == 0)
              {
                  [self openImagePickerWithSourcheType:UIImagePickerControllerSourceTypeCamera];
                  
              }
              else
              {
                  [self openImagePickerWithSourcheType:UIImagePickerControllerSourceTypePhotoLibrary];
              }
              [actionSheet removeFromSuperview];
              
          }] showInView];
        //用户信息页面
    }
    else if(indexPath.section==1&&indexPath.row==0)
    {
        //修改密码
        HBChangePaw *changePwd = [[HBChangePaw alloc]init];
        [self.navigationController pushViewController:changePwd animated:YES];
    }
    else if(indexPath.section==1&&indexPath.row==2)
    {
        //通知设置
    }
    else if(indexPath.section==2&&indexPath.row==0)
    {
        [self requestToGetIosEvaluateUrl];
        //给个好评
    }
    else if(indexPath.section==2&&indexPath.row==2)
    {
        //问题吐槽
        HBFeedBackCtrl *feed = [[HBFeedBackCtrl alloc]init];
        [self.navigationController pushViewController:feed animated:YES];
    }
    else if(indexPath.section==3&&indexPath.row==0)
    {
        if ([QQApiInterface isQQInstalled])
        {
            if (self.phoneInfo.customerServiceQQ.length>0)
            {
                UIWebView *webView = [[UIWebView alloc] initWithFrame:CGRectZero];
                NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:@"mqq://im/chat?chat_type=wpa&uin=%@&version=1&src_type=web",self.phoneInfo.customerServiceQQ]];
                NSURLRequest *request = [NSURLRequest requestWithURL:url];
                webView.delegate = self;
                [webView loadRequest:request];
                [self.view addSubview:webView];
                
//                QQApiWPAObject *wpaObj = [QQApiWPAObject objectWithUin:self.phoneInfo.customerServiceQQ];
//                SendMessageToQQReq *req = [SendMessageToQQReq reqWithContent:wpaObj];
//                QQApiSendResultCode sent = [QQApiInterface sendReq:req];
//                LLog(@"%d",sent);
                
            }
            
        }else{
            UIAlertView *alter = [[UIAlertView alloc]initWithTitle:@"提示" message:@"您还没有安装手机QQ" delegate:self cancelButtonTitle:@"确定" otherButtonTitles: nil];
            [alter show];
        }
        
        //QQ客服
    }
    else if(indexPath.section==3&&indexPath.row==2)
    {
        //客服热线
        [self clickToMakePhone];
        /*
         #import "CustomerBankCardSuc.h"
         #import "CustomerPhoneNum.h"
         #import "CustomerCardOwner.h"
         #import "CustomerTestView.h"
         #import "CustomMoneyNotEnogh.h"
         #import "CustomTradePassword.h"
         #import "CustomSuggestionAlert.h"
         #import "CustomReleaseBankBindAlert.h"
         */
        //银行卡绑定成功
//                [[[CustomerBankCardSuc alloc] initWithBankName:@"工商银行" withBankCard:@"ICBC"] showInView];
        //银行预留手机号码说明
        //        [[[CustomerPhoneNum alloc]initPhNum] showInView];
        //持卡人说明
        //        [[[CustomerCardOwner alloc]initCardOwner] showInView];
        //成功或者失败
//                [[[CustomerTestView alloc]initWithContent:@"成功了" TrueOrnot:YES] showInView];
        //投资时卡内余额不足
        //        [[[CustomMoneyNotEnogh alloc]initWithBankImName:@"ICBC" BankName:@"工商银行"] showInView];
        //输入交易密码
        //        [[[CustomTradePassword alloc]init] showTradPasswordAlertView];
        //密码错误提示，
//                [[[CustomSuggestionAlert alloc] init] showTradPasswordAlertView];
        //解绑银行卡，如果有投资余额的话的提示
        //        [[[CustomReleaseBankBindAlert alloc]init]showTradPasswordAlertView];
    }
    else if(indexPath.section==4)
    {
        //清楚缓存

        
    }
    
    
}

#pragma mark - net

- (void)requestToGetBankList
{
//    [CustomLoadingView showHudToView:self.view];
//    HBGetBankListParam *param = [[HBGetBankListParam alloc]init];
//    param.uid = [HBLoginManager sharedHBLoginManager].currentUserInfo.uid;
//    param.token = [HBLoginManager sharedHBLoginManager].currentUserInfo.token;
//    HBGetBankListParser *parser = [[HBGetBankListParser alloc]init];
//    [NetCenter getDataFromURL:Method_getBankList params:param parser:parser result:^(ParserResult *myResult) {
//        [CustomLoadingView hideHudForView:self.view];
//        if (myResult.code==0)
//        {
//            HBGetBankListInfo *listInfo = (HBGetBankListInfo *)myResult.result;
//            self.bankListInfo = listInfo;
//            [self.tableView reloadData];
//        }
//        else
//        {
//            DISSMISS_ERR(myResult.message);
//        }
//        
//    } failure:^(NSError *error) {
//        [CustomLoadingView hideHudForView:self.view];
//        DISSMISS_ERR([error description]);
//    }];
}

- (void)requestToUploadImgWithImageData:(NSData *)imageData;
{
    [CustomLoadingView showHudToView:self.view];
    HBUploadImgParam *param = [[HBUploadImgParam alloc]init];
    param.uid = [HBLoginManager sharedHBLoginManager].currentUserInfo.uid;
    param.token = [HBLoginManager sharedHBLoginManager].currentUserInfo.token;
    param.file = imageData;
    
    HBUploadImgParser *parser = [[HBUploadImgParser alloc]init];
    [NetCenter postDataFromURL:Method_uploadImg params:param parser:parser result:^(ParserResult *myResult) {
                [CustomLoadingView hideHudForView:self.view];
                if (myResult.code==0)
                {
                    HBUploadImgInfo *info = (HBUploadImgInfo *)myResult.result;
                    [HBLoginManager sharedHBLoginManager].currentUserInfo.headImg = info.headImg;
                    [HBLoginManager cacheCurrentUserToUserDefault:[HBLoginManager sharedHBLoginManager].currentUserInfo];
                    [self.tableView reloadSections:[NSIndexSet indexSetWithIndex:0] withRowAnimation:UITableViewRowAnimationFade];
                }
                else
                {
                    DISSMISS_ERR(myResult.message);
                }
        
    } failure:^(NSError *error) {
                [CustomLoadingView hideHudForView:self.view];
                DISSMISS_ERR([error description]);
    }];
}

- (void)requestTologout
{
    [CustomLoadingView showHudToView:self.view];
    HBLogoutParam *param = [[HBLogoutParam alloc]init];
    param.token = [HBLoginManager sharedHBLoginManager].currentUserInfo.token;
    param.uid = [HBLoginManager sharedHBLoginManager].currentUserInfo.uid;
    
    HBLogoutParser *parser = [[HBLogoutParser alloc]init];
    [NetCenter postDataFromURL:Method_logout params:param parser:parser result:^(ParserResult *myResult) {
        [CustomLoadingView hideHudForView:self.view];
        if (myResult.code==0)
        {
            [HBLoginManager didLoginOut];
        }
        else
        {
            DISSMISS_ERR(myResult.message);
            
        }
        
    } failure:^(NSError *error) {
        [CustomLoadingView hideHudForView:self.view];
        DISSMISS_ERR([error description]);
    }];
}

- (void)requestToOpenPush
{
    [CustomLoadingView showHudToView:self.view];
    HBUserOpenPushParam *param = [[HBUserOpenPushParam alloc]init];
    param.token = [HBLoginManager sharedHBLoginManager].currentUserInfo.token;
    param.uid = [HBLoginManager sharedHBLoginManager].currentUserInfo.uid;
    
    HBUserOpenPushParser *parser = [[HBUserOpenPushParser alloc]init];
    [NetCenter postDataFromURL:Method_userOpenPush params:param parser:parser result:^(ParserResult *myResult) {
        [CustomLoadingView hideHudForView:self.view];
        if (myResult.code==0)
        {
            [HBGetUserInfoManager requestToGetUserInfoWithResult:^(BOOL isSuccess, NSString *msg, NSError *error) {
                
            }];
        }
        else
        {
            DISSMISS_ERR(myResult.message);
            [self.tableView reloadSections:[NSIndexSet indexSetWithIndex:1] withRowAnimation:UITableViewRowAnimationAutomatic];
        }
        
    } failure:^(NSError *error) {
        [CustomLoadingView hideHudForView:self.view];
        DISSMISS_ERR([error description]);
        [self.tableView reloadSections:[NSIndexSet indexSetWithIndex:1] withRowAnimation:UITableViewRowAnimationAutomatic];
    }];
}

- (void)requestToClosePush
{
    [CustomLoadingView showHudToView:self.view];
    HBUserClosePushParam *param = [[HBUserClosePushParam alloc]init];
    param.token = [HBLoginManager sharedHBLoginManager].currentUserInfo.token;
    param.uid = [HBLoginManager sharedHBLoginManager].currentUserInfo.uid;
    
    HBUserClosePushParser *parser = [[HBUserClosePushParser alloc]init];
    [NetCenter postDataFromURL:Method_userClosePush params:param parser:parser result:^(ParserResult *myResult) {
        [CustomLoadingView hideHudForView:self.view];
        if (myResult.code==0)
        {
            [HBGetUserInfoManager requestToGetUserInfoWithResult:^(BOOL isSuccess, NSString *msg, NSError *error) {
                
            }];
        }
        else
        {
            DISSMISS_ERR(myResult.message);
            [self.tableView reloadSections:[NSIndexSet indexSetWithIndex:1] withRowAnimation:UITableViewRowAnimationAutomatic];
        }
        
    } failure:^(NSError *error) {
        [CustomLoadingView hideHudForView:self.view];
        DISSMISS_ERR([error description]);
        [self.tableView reloadSections:[NSIndexSet indexSetWithIndex:1] withRowAnimation:UITableViewRowAnimationAutomatic];
    }];
}

- (void)requestToGetServicePhone
{
    [CustomLoadingView showHudToView:self.view];
    HBGetCustomerServicePhoneParam *param = [[HBGetCustomerServicePhoneParam alloc]init];
    
    HBGetCustomerServicePhoneParser *parser = [[HBGetCustomerServicePhoneParser alloc]init];
    [NetCenter getDataFromURL:Method_getCustomerServicePhone params:param parser:parser result:^(ParserResult *myResult) {
        [CustomLoadingView hideHudForView:self.view];
        if (myResult.code==0)
        {
            HBGetCusomterServicePhoneInfo *phoneInfo = (HBGetCusomterServicePhoneInfo *)myResult.result;
            self.phoneInfo = phoneInfo;
        }
        else
        {
            DISSMISS_ERR(myResult.message);
            [self.tableView reloadSections:[NSIndexSet indexSetWithIndex:3] withRowAnimation:UITableViewRowAnimationAutomatic];
        }
        
    } failure:^(NSError *error) {
        [CustomLoadingView hideHudForView:self.view];
        DISSMISS_ERR([error description]);
    }];
}

- (void)requestToGetIosEvaluateUrl
{
    [CustomLoadingView showHudToView:self.view];
    HBGetIosEvaluateUrlParam *param = [[HBGetIosEvaluateUrlParam alloc]init];
    
    HBGetIosEvaluateUrlParser *parser = [[HBGetIosEvaluateUrlParser alloc]init];
    [NetCenter getDataFromURL:Method_getIosEvaluateUrl params:param parser:parser result:^(ParserResult *myResult) {
        [CustomLoadingView hideHudForView:self.view];
        if (myResult.code==0)
        {
            HBGetIosEvaluateUrlInfo *phoneInfo = (HBGetIosEvaluateUrlInfo *)myResult.result;
            
            [[UIApplication sharedApplication] openURL:[NSURL URLWithString:phoneInfo.dataInfo]];
            
        }
        else
        {
            DISSMISS_ERR(myResult.message);
  
        }
        
    } failure:^(NSError *error) {
        [CustomLoadingView hideHudForView:self.view];
        DISSMISS_ERR([error description]);
    }];
}


@end
